package com.yupi.yupicturebackend.model.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * @author: dh
 * @date: 2025-10-28 10:27
 */
@Getter
public enum SpaceLevelEnum {

    COMMON("普通版", 0, 100, 100L * 1024 * 1024),
    PROFESSIONAL("专业版", 1, 1000, 1000L * 1024 * 1024),
    FLAGSHIP("旗舰版", 2, 10000, 10000L * 1024 * 1024);

    /**
     * 空间等级
     */
    private final String text;

    /**
     * 值
     */
    private final int value;

    /**
     * 最大图片总数
     */
    private final long maxCount;

    /**
     * 最大图片总大小
     */
    private final long maxSize;

    SpaceLevelEnum(String text, int value, long maxCount, long maxSize) {

        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }

    public static SpaceLevelEnum getEnumByValue(Integer value) {

        if (ObjectUtil.isEmpty(value)) {

            return null;
        }
        for (SpaceLevelEnum spaceLevelEnum : SpaceLevelEnum.values()) {

            if (spaceLevelEnum.value == value) {

                return spaceLevelEnum;
            }
        }
        return null;
    }
}
